﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;
using System.Collections;
using System.Threading;

namespace PassportManage
{
    public partial class Form_Save : Form
    {
        public Form_Save()
        {
            InitializeComponent();
            PassportInfoList = new ArrayList();
        }
        //private PassportSavingState PSavingState;
        //int[] Angle = new int[BLL.Properties.Settings.Default.PillarCount];
        ArrayList PassportInfoList;
        private void tbTaskCode_KeyDown(object sender, KeyEventArgs e)
        {
            WFNetLib.Log.SystemLogData l = new WFNetLib.Log.SystemLogData();
            if (e.KeyValue == 13)//扫描结束
            {                
                string taskCode;                
                if(radioButton1.Checked)//单次扫描的
                {
                    BLL.PassportSerialPort PSP = new BLL.PassportSerialPort(255);
                    PSP.Display(1, 1, 1);
//                      if(PSavingState==PassportSavingState.WaitingScan)//当前等待扫描
//                      {                         
                         taskCode = tbTaskCode.Text.ToUpper();                         
                         tbTaskCode.Text = "";
                         PassportInfoData p;
                         p = AddPassportInfo(taskCode);                         
                         //p.ViewItem.BackColor = Color.Red; 
                         if (p != null)
                         {
// //                              string tx = string.Format("#Scan,{0,9},{1,6},{2:yyyy-MM-dd}*sum", p.TaskCode, p.Name, p.Birthday);
// //                              PSP.PCDisplay(tx);
//                              //PSavingState = PassportSavingState.WaitingInsert;
//                              BLL.MovingPlatform MP = new BLL.MovingPlatform();
//                              for (int i = 0; i < BLL.Properties.Settings.Default.PillarCount; i++)
//                              {
//                                  if (Angle[i] != GetSaveRegion(i))
//                                  {
//                                      if (!MP.Moving(i + 1, GetAngle(Angle[i]), true))
//                                      {
//                                          WFNetLib.Log.SystemLogData log = new WFNetLib.Log.SystemLogData();
//                                          log.LogType = LogType.探测相关.ToString();
//                                          log.LogContent = string.Format("电机未进行回转:柱子:{0},格数:{1}", i + 1, GetAngle(Angle[i]));
//                                          log.LogRemark = "电机转动";
//                                          log.InserSQLLog();
//                                      }
//                                      if (!MP.Moving(i + 1, GetAngle(GetSaveRegion(i)), false))
//                                      {
//                                          listView1.Items.Remove(p.ViewItem);
//                                          return;
//                                      }
//                                      Angle[i] = GetSaveRegion(i);
//                                  }
//                              }                             
                             BLL.GetPassportPosition GetP = new BLL.GetPassportPosition();
                             if(GetP.GetPosition(true,p))
                             {
                                 if (GetP.PositionList.Count == 1)
                                 {
                                     int Pillar = ((BLL.Position)(GetP.PositionList[0])).Pillar;
                                     int Layer = ((BLL.Position)(GetP.PositionList[0])).Layer;
                                     int Cell = ((BLL.Position)(GetP.PositionList[0])).Cell;
                                     p.Pillar = Pillar;
                                     p.Layer = Layer;
                                     p.Cell = Cell;                                     
                                     p.ViewItem.SubItems.Add((p.Layer-1).ToString());
                                     p.ViewItem.SubItems.Add(((int)((p.Cell - 1) / 10)).ToString());
                                     p.ViewItem.SubItems.Add(((int)((p.Cell - 1) % 10)).ToString());
                                     toolStripStatusLabel2.Text = (p.Layer - 1).ToString();
                                     toolStripStatusLabel4.Text = ((int)((p.Cell - 1) / 10)).ToString();
                                     toolStripStatusLabel6.Text = ((int)((p.Cell - 1) % 10)).ToString();
                                     BLL.PassportInfo bPI = new BLL.PassportInfo();
                                     if (!bPI.SavePassport(p))
                                     {
                                         MessageBox.Show("当前护照信息存储失败!");
                                         listView1.Items.Remove(p.ViewItem);
                                         return;
                                     }
                                     p.ViewItem.BackColor = Color.FromKnownColor(KnownColor.Window);
                                 }
                                 else if(GetP.PositionList.Count>1)
                                 {
//                                      Form_MultiPassportChoice f = new Form_MultiPassportChoice(GetP.PositionList);
//                                      if (f.ShowDialog() == DialogResult.OK)
//                                      {
//                                          int Pillar = f.Pillar;
//                                          int Layer = f.Layer;
//                                          int Cell = f.Cell;
//                                          p.Pillar = Pillar;
//                                          p.Layer = Layer;
//                                          p.Cell = Cell;
//                                          p.ViewItem.SubItems.Add(p.Pillar.ToString());
//                                          p.ViewItem.SubItems.Add((p.Layer-1).ToString());
//                                          p.ViewItem.SubItems.Add((p.Cell-1).ToString());
//                                          BLL.PassportInfo bPI = new BLL.PassportInfo();
//                                          if (!bPI.SavePassport(p))
//                                          {
//                                              MessageBox.Show("当前护照信息存储失败!");
//                                              listView1.Items.Remove(p.ViewItem);
//                                              return;
//                                          }
//                                          p.ViewItem.BackColor = Color.FromKnownColor(KnownColor.Window);
//                                      }
//                                      else
//                                      {
//                                          listView1.Items.Remove(p.ViewItem);
//                                          tbTaskCode.Text = "";
//                                          tbTaskCode.Focus();
//                                      }
                                     MessageBox.Show("检测位置有误，请重新进行此护照的存放！！！");
                                     listView1.Items.Remove(p.ViewItem);
                                     tbTaskCode.Text = "";
                                     tbTaskCode.Focus();
                                 }
                             }
                             else
                             {
                                 listView1.Items.Remove(p.ViewItem);
                                 tbTaskCode.Text = "";
                                 tbTaskCode.Focus();
                             }
                             //PSavingState = PassportSavingState.WaitingScan;
                         //}
                     }
                }
                else if (radioButton2.Checked)//连续扫描
                {
                    if (radioButton3.Checked)
                    {
                        taskCode = tbTaskCode.Text;
                        PassportInfoData p;
                        p = AddPassportInfo(taskCode);
                        if (p != null)
                        {
                            p.ViewItem.BackColor = Color.Yellow;
                            PassportInfoList.Add(p);
                            tbTaskCode.Text = "";
                            tbTaskCode.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("请确定当前的操作状态：“扫描”或者“插入”！");
                        tbTaskCode.Text = "";
                        tbTaskCode.Focus();
                    }
                }               
            }
        }    

        private void Form_Save_Load(object sender, EventArgs e)
        {
            radioButton1.Checked = true;
            //PSavingState = PassportSavingState.WaitingScan;
//             for (int i = 0; i < BLL.Properties.Settings.Default.PillarCount; i++)
//             {
//                 Angle[i] = 0;
//             }
            while(tbTaskCode.Focus());
            axOCRB1.Init(0, 1, 0, 0);
        }
        private PassportInfoData AddPassportInfo(string taskCode)
        {            
            PassportInfoData p;
            /*ListViewItem item = listView1.Items.Add((listView1.Items.Count + 1).ToString());*/
            ListViewItem item = listView1.Items.Insert(0,(listView1.Items.Count + 1).ToString());
            item.SubItems.Add(taskCode);
            item.BackColor = Color.Red;                       
            BLL.GetPassportInfoFormServer gpif = new BLL.GetPassportInfoFormServer(taskCode);
            p=gpif.GetPassportInfo();
            if(p==null)
            {                             
                listView1.Items.Remove(item);
                tbTaskCode.Text = "";
                tbTaskCode.Focus();                
            }
            else
            {
                item.SubItems.Add(p.Name);
                item.SubItems.Add(p.Birthday.ToString("yyyy-MM-dd"));
                item.SubItems.Add(p.CardID);
                item.SubItems.Add(p.CardCode);
                item.SubItems.Add(p.OprationNumber);
                p.ViewItem = item;
            }
            return p;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)//单扫
            {
                PassportInfoList.Clear();
                groupBox1.Visible = false;
            }
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)//连扫
            {
                groupBox1.Visible = true;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
            }
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton3.Checked)//连扫-》扫描中
            {
                radioButton1.Enabled = false;
                PassportInfoList.Clear();
            }            
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {            
            if (radioButton4.Checked)//连扫-》插入中
            {
                radioButton1.Enabled = false;
                if (PassportInfoList.Count == 0)
                {
                    MessageBox.Show("之前并未连续扫入任何的护照条码，无法进行放入的操作");
                    radioButton4.Checked = false;
                    return;
                }
                while (PassportInfoList.Count != 0)
                {
                    BLL.PassportSerialPort PSP = new BLL.PassportSerialPort(255);
                    PSP.Display(1, 1, 1);
                    PassportInfoData p = (PassportInfoData)PassportInfoList[0];
                    p.ViewItem.BackColor = Color.Red;
//                     Boolean mpErr = false;
//                     BLL.MovingPlatform MP = new BLL.MovingPlatform();
//                     for (int i = 0; i < BLL.Properties.Settings.Default.PillarCount; i++)
//                     {
//                         if (Angle[i] != GetSaveRegion(i))
//                         {
//                             if (!MP.Moving(i + 1, GetAngle(Angle[i]), true))
//                             {
//                                 WFNetLib.Log.SystemLogData log = new WFNetLib.Log.SystemLogData();
//                                 log.LogType = LogType.探测相关.ToString();
//                                 log.LogContent = string.Format("电机未进行回转:柱子:{0},格数:{1}", i + 1, GetAngle(Angle[i]));
//                                 log.LogRemark = "电机转动";
//                                 log.InserSQLLog();
//                             }
//                             if (!MP.Moving(i + 1, GetAngle(GetSaveRegion(i)), false))
//                             {
//                                 listView1.Items.Remove(p.ViewItem);
//                                 mpErr = true;
//                                 break;
//                             }
//                             Angle[i] = GetSaveRegion(i);
//                         }
//                     }
//                     if (mpErr)
//                         continue;
                    BLL.GetPassportPosition GetP = new BLL.GetPassportPosition();
                    if (GetP.GetPosition(true, p))
                    {
                         if (GetP.PositionList.Count == 1)
                         {
                             int Pillar = ((BLL.Position)(GetP.PositionList[0])).Pillar;
                             int Layer = ((BLL.Position)(GetP.PositionList[0])).Layer;
                             int Cell = ((BLL.Position)(GetP.PositionList[0])).Cell;
                             p.Pillar = Pillar;
                             p.Layer = Layer;
                             p.Cell = Cell;
//                              p.ViewItem.SubItems.Add(p.Pillar.ToString());
//                              p.ViewItem.SubItems.Add((p.Layer-1).ToString());
//                              p.ViewItem.SubItems.Add((p.Cell-1).ToString());
                             p.ViewItem.SubItems.Add((p.Layer - 1).ToString());
                             p.ViewItem.SubItems.Add(((int)((p.Cell - 1) / 10)).ToString());
                             p.ViewItem.SubItems.Add(((int)((p.Cell - 1) % 10)).ToString());
                             toolStripStatusLabel2.Text = (p.Layer - 1).ToString();
                             toolStripStatusLabel4.Text = ((int)((p.Cell - 1) / 10)).ToString();
                             toolStripStatusLabel6.Text = ((int)((p.Cell - 1) % 10)).ToString();
                             BLL.PassportInfo bPI = new BLL.PassportInfo();
                             if (!bPI.SavePassport(p))
                             {
                                 MessageBox.Show("当前护照信息存储失败!");
                                 listView1.Items.Remove(p.ViewItem);
                                 continue;
                             }
                             p.ViewItem.BackColor = Color.FromKnownColor(KnownColor.Window);
                         }
                         else if (GetP.PositionList.Count > 1)
                         {
//                              Form_MultiPassportChoice f = new Form_MultiPassportChoice(GetP.PositionList);
//                              if (f.ShowDialog() == DialogResult.OK)
//                              {
//                                  int Pillar = f.Pillar;
//                                  int Layer = f.Layer;
//                                  int Cell = f.Cell;
//                                  p.Pillar = Pillar;
//                                  p.Layer = Layer;
//                                  p.Cell = Cell;
//                                  p.ViewItem.SubItems.Add(p.Pillar.ToString());
//                                  p.ViewItem.SubItems.Add((p.Layer-1).ToString());
//                                  p.ViewItem.SubItems.Add((p.Cell-1).ToString());
//                                  BLL.PassportInfo bPI = new BLL.PassportInfo();
//                                  if (!bPI.SavePassport(p))
//                                  {
//                                      MessageBox.Show("当前护照信息存储失败!");
//                                      listView1.Items.Remove(p.ViewItem);
//                                      return;
//                                  }
//                                  p.ViewItem.BackColor = Color.FromKnownColor(KnownColor.Window);
//                              }
//                              else
//                              {
//                                  listView1.Items.Remove(p.ViewItem);
//                              }
                             MessageBox.Show("检测位置有误，请重新进行此护照的存放！！！");
                             listView1.Items.Remove(p.ViewItem);
                         }
                    }
                    else
                    {
                        listView1.Items.Remove(p.ViewItem);                       
                    }
                    PassportInfoList.RemoveAt(0);
                    Thread.Sleep(1500);
                }
                radioButton4.Checked = false;
            }
        }

        private void button1_Click(object sender, EventArgs e)//取消连扫
        {
            if (MessageBox.Show("取消将丢失所有之前扫描并且未成功插入的护照信息！！\n确定要取消么？",
                                "注意",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
                == DialogResult.No)
                return;
            radioButton1.Enabled = true;
            radioButton3.Checked = false;
            radioButton4.Checked = false;
            while (PassportInfoList.Count != 0)
            {
                PassportInfoData p = (PassportInfoData)PassportInfoList[0];
                listView1.Items.Remove(p.ViewItem);
                PassportInfoList.RemoveAt(0);
            }
            PassportInfoList.Clear();
        }

        private void listView1_DoubleClick(object sender, EventArgs e)
        {            
            if (listView1.SelectedItems.Count == 0)
                return;
            if (radioButton3.Checked)
                return;
            if (radioButton4.Checked)
                return;
            ListViewItem item = listView1.SelectedItems[0];
            PassportInfoData p = new PassportInfoData();
            p.TaskCode = item.SubItems[1].Text;
            p.Name = item.SubItems[2].Text;
            p.Birthday = DateTime.Parse(item.SubItems[3].Text);
            p.CardID = item.SubItems[4].Text;
            p.CardCode = item.SubItems[5].Text;
            p.OprationNumber = item.SubItems[6].Text;
            p.Pillar = int.Parse(item.SubItems[7].Text);
            p.Layer = int.Parse(item.SubItems[8].Text);
            p.Cell = int.Parse(item.SubItems[9].Text);
            Form_ManualEidtPassport f = new Form_ManualEidtPassport(p);
            if (f.ShowDialog() == DialogResult.OK)
            {
                item.SubItems[1].Text = f.p.TaskCode;
                item.SubItems[2].Text = f.p.Name;
                item.SubItems[3].Text = f.p.Birthday.ToString("yyyy-MM-dd");
                item.SubItems[4].Text = f.p.CardID;
                item.SubItems[5].Text = f.p.CardCode;
                item.SubItems[6].Text = f.p.OprationNumber;
//                 item.SubItems[7].Text = f.p.Pillar.ToString();
//                 item.SubItems[8].Text = f.p.Layer.ToString();
//                 item.SubItems[9].Text = f.p.Cell.ToString();
                item.SubItems[7].Text = f.p.Layer.ToString();
                item.SubItems[8].Text = ((int)((f.p.Cell - 1) / 10)).ToString();
                item.SubItems[9].Text = ((int)((f.p.Cell - 1) % 10)).ToString();
            }
        }
        private int GetSaveRegion(int Pillar)
        {
            int[] r=new int[4];
            int rIndex;
            for (int i = 0; i < 4; i++)
            {
                r[i] = 0;
            }
            for (int layer = 0; layer < 10; layer++)
            {
                for (int board = 0; board < 8; board++)
                {
                    rIndex = GetRegion(board);
                    byte b;
                    b = BLL.GetPassportPosition.PillarState[Pillar, layer * 32 + board * 4 + 3];
                    if (WFNetLib.BytesOP.GetBit(b, 7))//当前板有故障
                    {
                        r[rIndex] += 0;
                        continue;
                    }
                    if (WFNetLib.BytesOP.GetBit(b, 0))
                    {
                        r[rIndex]++;
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        b = BLL.GetPassportPosition.PillarState[Pillar, layer * 32 + board * 4 + i];
                        for (int j = 0; j < 8; j++)
                        {
                            if (WFNetLib.BytesOP.GetBit(b, j))
                            {
                                r[rIndex]++;
                            }
                        }
                    }
                }
            }
            int count = r[0] / 100;
            if (count < 1)
                return 0;
            for (int i = 1; i < 4; i++)
            {
                if (r[i] < count * 100)
                    return i;
            }
            return 0;
        }
        private int GetRegion(int board)
        {
            switch (board)
            {
                case 0:
                    return 0;
                case 1:
                    return 1;
                case 2:
                    return 1;
                case 3:
                    return 2;
                case 4:
                    return 2;
                case 5:
                    return 3;
                case 6:
                    return 3;
                case 7:
                    return 0;
            }
            return 0;
        }
        private int GetAngle(int A)
        {
            switch (A)
            {
                case 0:
                    return 1;
                case 1:
                    return 51;
                case 2:
                    return 101;
                case 3:
                    return 151;
            }           
            return 0;
        }
        private void Form_Save_FormClosing(object sender, FormClosingEventArgs e)
        {
//             BLL.MovingPlatform MP = new BLL.MovingPlatform();
//             for (int i = 0; i < BLL.Properties.Settings.Default.PillarCount; i++)
//             {
//                 if (Angle[i] != 0)
//                 {
//                     if (!MP.Moving(i+1, GetAngle(Angle[i]), true))
//                     {
//                         WFNetLib.Log.SystemLogData log = new WFNetLib.Log.SystemLogData();
//                         log.LogType = LogType.探测相关.ToString();
//                         log.LogContent = string.Format("电机未进行回转:柱子:{0},格数:{1}", i + 1, GetAngle(Angle[i]));
//                         log.LogRemark = "电机转动";
//                         log.InserSQLLog();
//                     }
//                 }                
//             }
        }

        private void axOCRB1_ISNON(object sender, EventArgs e)
        {
            string str=string.Format("未知类型图片,图像路径:{0}",axOCRB1.GPaperPath());
            MessageBox.Show(str);
        }

        private void axOCRB1_ISHZ(object sender, EventArgs e)
        {
            WFNetLib.Log.SystemLogData l = new WFNetLib.Log.SystemLogData();
                string taskCode;
                if (radioButton1.Checked)//单次扫描的
                {
                    BLL.PassportSerialPort PSP = new BLL.PassportSerialPort(255);
                    PSP.Display(1, 1, 1);
                    //                      if(PSavingState==PassportSavingState.WaitingScan)//当前等待扫描
                    //                      {                         
                    taskCode = axOCRB1.GPassportNo().ToUpper();
                    tbTaskCode.Text = "";
                    PassportInfoData p;
                    p = AddPassportInfo(taskCode);
                    //p.ViewItem.BackColor = Color.Red; 
                    if (p != null)
                    {
//                         string tx = string.Format("#Scan,{0,9},{1,6},{2:yyyy-MM-dd}*sum", p.TaskCode, p.Name, p.Birthday);
//                         PSP.PCDisplay(tx);
//                         //PSavingState = PassportSavingState.WaitingInsert;
//                         BLL.MovingPlatform MP = new BLL.MovingPlatform();
//                         for (int i = 0; i < BLL.Properties.Settings.Default.PillarCount; i++)
//                         {
//                             if (Angle[i] != GetSaveRegion(i))
//                             {
//                                 if (!MP.Moving(i + 1, GetAngle(Angle[i]), true))
//                                 {
//                                     WFNetLib.Log.SystemLogData log = new WFNetLib.Log.SystemLogData();
//                                     log.LogType = LogType.探测相关.ToString();
//                                     log.LogContent = string.Format("电机未进行回转:柱子:{0},格数:{1}", i + 1, GetAngle(Angle[i]));
//                                     log.LogRemark = "电机转动";
//                                     log.InserSQLLog();
//                                 }
//                                 if (!MP.Moving(i + 1, GetAngle(GetSaveRegion(i)), false))
//                                 {
//                                     listView1.Items.Remove(p.ViewItem);
//                                     return;
//                                 }
//                                 Angle[i] = GetSaveRegion(i);
//                             }
//                         }
                        BLL.GetPassportPosition GetP = new BLL.GetPassportPosition();
                        if (GetP.GetPosition(true, p))
                        {
                            if (GetP.PositionList.Count == 1)
                            {
                                int Pillar = ((BLL.Position)(GetP.PositionList[0])).Pillar;
                                int Layer = ((BLL.Position)(GetP.PositionList[0])).Layer;
                                int Cell = ((BLL.Position)(GetP.PositionList[0])).Cell;
                                p.Pillar = Pillar;
                                p.Layer = Layer;
                                p.Cell = Cell;
//                                 p.ViewItem.SubItems.Add(p.Pillar.ToString());
//                                 p.ViewItem.SubItems.Add((p.Layer-1).ToString());
//                                 p.ViewItem.SubItems.Add((p.Cell-1).ToString());
                                p.ViewItem.SubItems.Add((p.Layer - 1).ToString());
                                p.ViewItem.SubItems.Add(((int)((p.Cell - 1) / 10)).ToString());
                                p.ViewItem.SubItems.Add(((int)((p.Cell - 1) % 10)).ToString());
                                toolStripStatusLabel2.Text = (p.Layer - 1).ToString();
                                toolStripStatusLabel4.Text = ((int)((p.Cell - 1) / 10)).ToString();
                                toolStripStatusLabel6.Text = ((int)((p.Cell - 1) % 10)).ToString();
                                BLL.PassportInfo bPI = new BLL.PassportInfo();
                                if (!bPI.SavePassport(p))
                                {
                                    MessageBox.Show("当前护照信息存储失败!");
                                    listView1.Items.Remove(p.ViewItem);
                                    return;
                                }
                                p.ViewItem.BackColor = Color.FromKnownColor(KnownColor.Window);
                            }
                            else if (GetP.PositionList.Count > 1)
                            {
//                                 Form_MultiPassportChoice f = new Form_MultiPassportChoice(GetP.PositionList);
//                                 if (f.ShowDialog() == DialogResult.OK)
//                                 {
//                                     int Pillar = f.Pillar;
//                                     int Layer = f.Layer;
//                                     int Cell = f.Cell;
//                                     p.Pillar = Pillar;
//                                     p.Layer = Layer;
//                                     p.Cell = Cell;
//                                     p.ViewItem.SubItems.Add(p.Pillar.ToString());
//                                     p.ViewItem.SubItems.Add((p.Layer-1).ToString());
//                                     p.ViewItem.SubItems.Add((p.Cell-1).ToString());
//                                     BLL.PassportInfo bPI = new BLL.PassportInfo();
//                                     if (!bPI.SavePassport(p))
//                                     {
//                                         MessageBox.Show("当前护照信息存储失败!");
//                                         listView1.Items.Remove(p.ViewItem);
//                                         return;
//                                     }
//                                     p.ViewItem.BackColor = Color.FromKnownColor(KnownColor.Window);
//                                 }
//                                 else
//                                 {
//                                     listView1.Items.Remove(p.ViewItem);
//                                     tbTaskCode.Text = "";
//                                     tbTaskCode.Focus();
//                                 }
                                MessageBox.Show("检测位置有误，请重新进行此护照的存放！！！");
                                listView1.Items.Remove(p.ViewItem);
                                tbTaskCode.Text = "";
                                tbTaskCode.Focus();
                            }
                        }
                        else
                        {
                            listView1.Items.Remove(p.ViewItem);
                            tbTaskCode.Text = "";
                            tbTaskCode.Focus();
                        }
                        //PSavingState = PassportSavingState.WaitingScan;
                        //}
                    }
                }
                else if (radioButton2.Checked)//连续扫描
                {
                    if (radioButton3.Checked)
                    {
                        taskCode = axOCRB1.GPassportNo().ToUpper();
                        PassportInfoData p;
                        p = AddPassportInfo(taskCode);
                        if (p != null)
                        {
                            p.ViewItem.BackColor = Color.Yellow;
                            PassportInfoList.Add(p);
                            tbTaskCode.Text = "";
                            tbTaskCode.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("请确定当前的操作状态：“扫描”或者“插入”！");
                        tbTaskCode.Text = "";
                        tbTaskCode.Focus();
                    }
                }
        }
       
    }
}
